package com.xwd.web.student;

import com.xwd.domain.Grade;
import com.xwd.domain.Student;
import com.xwd.service.GradeService;
import com.xwd.service.StudentService;
import com.xwd.service.impl.GradeServiceImpl;
import com.xwd.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/getupdateStudent")
public class GetUpdateStudentServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //接受参数
        String stuId = req.getParameter("stuId");
        int stuid = Integer.parseInt(stuId);
        //掉用service方法
        StudentService service = new StudentServiceImpl();
        Student byId = service.findById(stuid);

        //获得class集合
        GradeService gradeService = new GradeServiceImpl();
        List<Grade> glist = gradeService.getClassTotalName();

        //保存参数放回
        req.setAttribute("glist",glist);
        req.setAttribute("byid", byId);
        req.getRequestDispatcher("/Educational/student/edit.jsp").forward(req, resp);
    }
}